﻿using System;
using System.Collections.Generic;

namespace Moebius.Profiling
{
    public sealed class ProfileResults
    {
        private readonly ProfileIteration[] iterations;

        internal ProfileResults(ICollection<ProfileIteration> profileIterations)
        {
            iterations = new ProfileIteration[profileIterations.Count];
            profileIterations.CopyTo(Iterations, 0);
            Array.Sort(Iterations, delegate(ProfileIteration lhs, ProfileIteration rhs)
            {
                if (lhs.Iterations < rhs.Iterations)
                    return -1;
                else if (lhs.Iterations > rhs.Iterations)
                    return 1;
                else
                    return 0;
            });
        }

        public ProfileIteration[] Iterations
        {
            get { return iterations; }
        }
    }
}